﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KPIS.GERP.ESS.APP.App_UI.Forms
{
    public partial class GIMS_PrePurchase : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                var strUrls = Request.RawUrl.Split(new[]{"ExternalPage.aspx?Url="}, StringSplitOptions.RemoveEmptyEntries);
                Url = strUrls[1]; 
                Url = HttpUtility.UrlDecode(Url); 
                Url = Url.Replace("@1", SsMng.LeftUrlWithPrefix); 
                Url = (Request.Url.ToString().ToLower().StartsWith("https") ? Url.Replace("http://", "https://") : Url); 
                //   /ESS/APP_UI/Forms/ExternalPage.aspx?Url=http://@1/WEB.GIMS/Home/SingleSigonCookie?redirectPage=../Prepurchase'QEmptyLayout=true&isEncode64=false

                string splitWord = "redirectPage=";
                int indexSplit = Url.IndexOf(splitWord) + splitWord.Length;
                //string urlPath1 = Url.Substring(0, indexSplit);
                //string urlPath2 = HttpUtility.UrlEncode(Url.Substring(indexSplit).Replace("'", "&apos;"));
                //Url = urlPath1 + urlPath2;
                //Response.Write("urlPath1=" + urlPath1 + ", urlPath2=" + urlPath2);
            }
        }

        public string Url { get; set; }
    }
}